home *** CD-ROM | disk | FTP | other *** search
Wrap
# Source Generated with Decompyle++ # File: in.pyc (Python 2.4) ''' Tests for commands module Nick Mathewson ''' import unittest import os import tempfile import re from test.test_support import TestSkipped, run_unittest from commands import * if os.name != 'posix': raise TestSkipped('Not posix; skipping test_commands') class CommandTests(unittest.TestCase): def test_getoutput(self): self.assertEquals(getoutput('echo xyzzy'), 'xyzzy') self.assertEquals(getstatusoutput('echo xyzzy'), (0, 'xyzzy')) dir = None try: dir = tempfile.mkdtemp() name = os.path.join(dir, 'foo') (status, output) = getstatusoutput('cat ' + name) self.assertNotEquals(status, 0) finally: if dir is not None: os.rmdir(dir) def test_getstatus(self): pat = 'd......... # It is a directory.\n \\+? # It may have ACLs.\n \\s+\\d+ # It has some number of links.\n [^/]* # Skip user, group, size, and date.\n /\\. # and end with the name of the file.\n ' self.assert_(re.match(pat, getstatus('/.'), re.VERBOSE)) def test_main(): run_unittest(CommandTests) if __name__ == '__main__': test_main()